#!/usr/bin/python

import re

def readConf(filename="."):
	"""read files that have lines of the form: KEY=VAL, return dictionary with each asentries"""
	file_object = open(filename)
	try:
		print file_object
		lines  = file_object.read().split('\n')
	finally:
		file_object.close()
	lines = map(lambda x:  x.strip(), lines) #remove spaces fro beginning and end
	conf = {} #where we'll store our configuration attributes
	for line in lines:
		if re.search('^(#|\/\/)', line): #skip comment lines
			continue 
		matchConf = re.search('(\w+)=(\S+)', line) #attempt getting config pair
		if matchConf != None:
			(key, val) = matchConf.groups() #attempt getting config pair
		else:
			continue
		if (key == None ):
			continue
		conf[key] = val #otherwise we have something to config so store it	
	return conf

	
if __name__ == '__main__':
	readConf(filename="equal.conf")
